All Questions
35 questions
0votes
2answers
205views
Command-line tool enabling tagging and related tags functionality
Is there a command-line tool that enables to give a file more attributes than a name? For example, we have a file called ubuntu.pdf and we give it tags like command-line, shell, nautilus, ...
0votes
0answers
36views
How to properly format the command argument for sudo? [duplicate]
I have a command that is similar to this minimal example: $ sh -c 'echo "1=$1"' _ foo 1=foo $ When I want to run it through sudo, it stops working: $ sudo -i -u user -- sh -c 'echo "1=...
0votes
4answers
837views
Bash: convert 100,000+ characters to decimal format?
I'm looking for a quick and not-so CPU intensive solution to convert 100,000+ lines of text into decimal format. # random ascii string='QPWOEIRUTYALSKDJFHGZMXNCBV,./;[]75498053$#!@*&^%(*' convert ...
1vote
2answers
702views
Function to go forward one directory, if possible?
I use below code snippet (by pressing alt-h), to go backward one level of current directory. up-dir() { cd ".." zle reset-prompt } zle -N up-dir bindkey "^[h" up-dir I want similar ...
-2votes
1answer
181views
How to include interaction with the command in the same script?
I have written a script to run a specific program, my script contains many steps, some of these steps need my simple interaction by writing 0 then enter, How can I do that so that I don't need to ...
6votes
1answer
8kviews
How to abort if ssh control socket already exists?
I'm using the following line in my scripts: ssh -f -N -M -S <control socket> <host> This means the initial connection just stays in the background and I can use it for subsequent calls to ...
0votes
1answer
89views
How can I display the largest common part of two files?
I know how to use comm, diff or grep to display every common line of two files. But how can I display only the largest common part, i. e. the most common lines in succession? (If there are equally ...
12votes
2answers
13kviews
How can I do an if conditional for a failure of a bash command?
I'd like to have a very simple condition that will only execute if the command fails. In this example it's a conditional based on the SUCCESS of the command. if command ; then echo "Command ...
2votes
3answers
6kviews
Progress bar to display progress based on number of files found/completed in for loop?
Is there a progress bar that can show visually completed progress based on the number of detected files found and completed in a for loop like the one below? mkdir -p hflip; for i in *.mp4; do ffmpeg ...
-1votes
1answer
50views
Why is this bash script read line code giving me errors? [closed]
Why is this bash script read line code giving me errors? read -p "Does this require cropping? (y/n)? " answer case ${answer:0:1} in y|Y ) mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:...
-1votes
1answer
93views
how to add additional command-line usage scenarios to script?
how can one make this script work with both input usage scenarios below? #1 ./script.sh #2 ./script.sh input.file contents of script.sh for i in *.mp4; do ffmpeg -i "$i" "${i%.*}.mp4 scenario ...
3votes
2answers
8kviews
How to include custom command options in a bash script with $1 and $2?
I have a script myscript.sh #!/bin/sh echo $1 $2 which is used something like ... ./myscript.sh foo bar which gives me an output of ... foo bar but how can i make this script include custom ...
0votes
2answers
218views
Concatenate the Content of Files from Various Directories with a Blank Line in Between
I have the file dir1.txt that contains the names of the following directories: 2 3 4 Directory 2 contains files 2_1.txt and 2_2.txt Directory 3 contains files 3_1.txt and 3_2.txt Directory 4 contains ...
2votes
1answer
615views
How to modify these bash functions into one?
Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time. ...
3votes
2answers
11kviews
Bash: Timer in while loop
I have a while loop in my script which waits for the connection get online and then continues. #!/bin/sh while ! ping -c1 $1 &>/dev/null do echo "Ping Fail - `date`" done echo "Host ...